home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
qbnws104.zip
/
FOSSIL.ZIP
/
FOSSIL1.BAS
next >
Wrap
BASIC Source File
|
1990-09-03
|
5KB
|
180 lines
'Baud and Commport should be global variables already set in the main
'module. Baud should probably be a long integer.
'LocalPrint (Text$) should be a Sub that prints Text$ on the local
'screen
'These should be declared in your FOSSIL-module-level code
DIM SHARED InRegs2 AS RegType2
DIM SHARED InReg AS RegType
DIM SHARED OutRegs2 AS RegType2
DIM SHARED OutReg AS RegType
'
SUB Deinit 'Deinitialize the FOSSIL..._always_ deinit on program exit
InReg.AX = 1280
InReg.DX = Commport
Interrupt &H14, InReg, OutReg
END SUB
SUB FossilCD (Status) 'Check modem status, check for carrier
STATIC InRegs AS RegType
STATIC OutRegs AS RegType
InRegs.AX = 768 'Remember, AX is (AH * 256) + AL
InRegs.DX = Commport
Interrupt &H14, InRegs, OutRegs
Status = OutRegs.AX / 256 'This gets us register AH's value
'Inputt = abs((Status AND 1 + Carrier[1]) > 0) 'Additional info if
'Outputt = abs((Status AND 32) > 0) 'anyone wants it
'NoOut= abs((Status AND 64) > 0)<>0
IF Baud THEN
IF ABS(((OutRegs.AX - (Status * 256)) AND 128) > 0) = 0 THEN
'^ ^--Carrier mask
DeInit '|
END 'Lost carrier '\__Subtracting AH * 256 from AX gives us AL
END IF
END IF
END SUB
'
SUB FossilDTR (UpDown) 'UpDown=1 means DTR up...0 means DTR down
HowMany = 0
Hangup:
AH = &H6: AL = UpDown
GOSUB DoItToIt
IF UpDown = 1 THEN EXIT SUB
SLEEP 1 'From here down we're checking to see if we cleared the
AH = &H6: AL = 1 'line. We'll try a few more times if not.
GOSUB DoItToIt
AH = &H3: AL = 0
InReg.DX = Commport
GOSUB DoItToIt
IF ABS(((OutReg.AX - Status * 256) AND 128) > 0) = 0 THEN
AH = &H6
AL = 0
GOSUB DoItToIt
EXIT SUB
END IF
HowMany = HowMany + 1
IF HowMany < 7 THEN
GOTO Hangup
ELSE
AH = &H6
AL = 0
GOSUB DoItToIt
EXIT SUB
END IF
DoItToIt:
InReg.AX = AH * 256 + AL
InReg.DX = Commport
Interrupt &H14, InReg, OutReg
RETURN
END SUB
'
FUNCTION FossilGet$ 'Equivalent of INKEY$ for FOSSIL
FossilGet$ = ""
IF Baud THEN
FossilCD Status
IF ABS((Status AND 1 + 1) > 0) = 0 THEN EXIT SUB 'No input waiting
InReg.AX = 512
InReg.DX = Commport
Interrupt &H14, InReg, OutReg
FossilGet$ = CHR$((OutReg.AX - INT(OutReg.AX / 256) * 256))
END IF
END SUB
'
SUB FossilInit 'Initialize FOSSIL
InReg.AX = 1024
InReg.DX = Commport
Interrupt &H14, InReg, OutReg
IF OutReg.AX <> &H1954 THEN
Print "FOSSIL is braindead!"
DeInit
END
END IF
InReg.AX = 4088 'Check FOSSIL.DOC for these...you may
Interrupt &H14, InReg, OutReg 'want to modify these calls for your
InReg.AX = 4096 'own setup
Interrupt &H14, InReg, OutReg
END SUB
'
SUB FossilPos (PutGet, Row, Col) 'PutGet=0 means put, =1 means get
'Use this instead of LOCATE if you
'print on local screen through CONS:
InReg.DX = Row * 256 + Col
InReg.AX = 4352 + ABS(PutGet)
Interrupt &H14, InReg, OutReg
IF PutGet THEN Row = OutReg.DX / 256: Col = OutReg.DX -_
INT(OutReg.DX / 256) * 256
END SUB
'
SUB FossilPurge (OutIn) 'Purge input (OutIn=0=Out, 1=In, 2=Both)
'Purges inbound and/or outbound FOSSIL
'buffer(s)
IF OutIn = 0 THEN InReg.AX = 2304 ELSE InReg.AX = 2560
GOSUB Purger
IF OutIn = 2 THEN InReg.AX = 2304: GOSUB Purger
EXIT SUB
Purger:
InReg.DX = Commport
Interrupt &H14, InReg, OutReg
RETURN
END SUB
'
SUB Hold 'Wait until output clears outbound FOSSIL buffer
IF Baud THEN
DO
FossilCD Status
LOOP UNTIL (ABS((Status AND 64) > 0))
END IF
END SUB
'
SUB ModemOut (Text$) 'Send a string to the modem
IF Text$ = "" THEN EXIT SUB 'Goof-up protection
IF Baud THEN
Temp = LEN(Text$)
FOR X = 1 TO Temp 'Put each char into outbound buffer
InReg.AX = (&HB * 256) + ASC(MID$(Text$, X, 1))
InReg.DX = Commport
DO
Interrupt &H14, InReg, OutReg
IF OutReg.AX = 0 THEN FossilCD Status 'Buffer was full
LOOP WHILE OutReg.AX = 0 'Try again
NEXT
END IF
LocalPrint Text$ 'Sub to print text locally (suggest CONS:)
IF Baud > 0 AND Baud < 4800 THEN Hold '<------------------------,
'Optional, prevents excessive overrun__/
'You might want to make dependent on length
'of string sent
END SUB